﻿using System;
using System.Diagnostics;

namespace HgAdapter
{
	public class HgCommit: HgCommand
	{
		public void Run(string bracketFileName, string message)
		{
			string saveCurrentDirectory = Environment.CurrentDirectory;
			Environment.CurrentDirectory = ProjectCommitInfo.Instance.ProjectPath;
			
			string messageOption = message.Length == 0 ? string.Empty : "-m \"" + message + "\"";

			Process hgProcess = Process.Start(HgStatusStartInfo("commit " + messageOption + 
				" " + bracketFileName));
			hgProcess.WaitForExit();

			Environment.CurrentDirectory = saveCurrentDirectory;
		}
	}
}
